package threadlocal;

/**
 * @Description: null
 * @Project: testDemo
 * @Author: hjibo
 * @CreateDate: 2019/3/8 09:54
 * @ModificationHistory: （who whatTime doWhat）
 */
public class Main {

    public static void main(String[] args) throws InterruptedException {

        User user = new User();
        user.setAddress("qqq");
        user.setName("小明");

        ThreadLocal<User> local = new ThreadLocal();

        new Thread(new Runnable() {
            @Override
            public void run() {
                local.set(user);
                local.get().setName("ccc");
                System.out.println(local.get().toString());
            }
        }).start();

        Thread.sleep(3000);

        new Thread(new Runnable() {
            @Override
            public void run() {
                local.set(user);
                System.out.println(local.get().toString());
            }
        }).start();



    }
}
